<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>添加管理员账号</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="../../css/font.css">
    <link rel="stylesheet" href="../../css/xadmin.css">
    <script type="text/javascript" src="../../js/jquery-3.2.1.js"></script>
    <script type="text/javascript" src="../../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../js/xadmin.js"></script>
  </head>
  
  </head>
  
  <body>
    <div class="x-body">
        <form action="" method="post" class="layui-form layui-form-pane">
                <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                        <span class="x-red">*</span>管理员账号
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="adminAcc" name="adminAcc" required="" lay-verify="required"
                        autocomplete="off" class="layui-input">
                    </div>
                    <span></span></br>
                    <span id="aaa">此账号可以使用</span>
                </div>
                <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                        <span class="x-red">*</span>密码
                    </label>
                    <div class="layui-input-inline">
                        <input type="password" id="adminPassword" name="adminPassword" required="" lay-verify="required"
                        autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                        <span class="x-red">*</span>确认密码
                    </label>
                    <div class="layui-input-inline">
                        <input type="password" id="readminPassword" name="readminPassword" required="" lay-verify="required"
                        autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                        <span></span>账号负责人
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="responsible" name="responsible" 
                        autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="name" class="layui-form-label">
                        <span></span>联系方式
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="telephone" name="telephone" 
                        autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item" style="width:400px;">
					<label class="layui-form-label"><spanclass="x-red">*</span>管理员类型</label>
					<div class="layui-input-block" id = "view">
						<select id="authority" name="authority">
							<option value="boss" >主管(一级管理员)</option>
							<option value="parking" >停车收费管理员(二级管理员)</option>
							<option value="pminfo" >物业信息管理员(二级管理员)</option>
							<option value="office" >办公室管理员(二级管理员)</option>
							<option value="clean" >保洁管理员(二级管理员)</option>
							<option value="security" >安保管理员(二级管理员)</option>
		  				</select>
					</div>
			</div>
                
                <div class="layui-form-item">
                <button class="layui-btn" lay-submit="" lay-filter="add">添加</button>
              </div>
            </form>
    </div>
    <script>
        layui.use(['form','layer'], function(){
          var form = layui.form
          ,layer = layui.layer;
        
          $("#aaa").css('color','green');
          $("#aaa").css('top','20px');

          //监听提交
          form.on('submit(add)', function(data){
        	  
        	  
            	var adminPassword = $("#adminPassword").val();
            	var readminPassword = $("#readminPassword").val();
              	
      			if(adminPassword == readminPassword){
              	
      	      	var json={};
      	            json.adminAcc=$("#adminAcc").val();
      	            json.adminPassword=$("#adminPassword").val();
      	          	json.responsible=$("#responsible").val();
      	        	json.telephone=$("#telephone").val();
      	      		json.authority=$("#authority").val();
      	          
      			
        	  
        	  
		            $.ajax({
		            	type: "post",
		            	url: "../../admin/addAdminacc",
		            	async: true,
		            	data: json,
		            	success: function(result) {
		            		if(result.msg == 'success') {
		              			layer.msg("添加成功",{icon:6,time:1500},function(){
		              				var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
		              				parent.layer.close(index); //再执行关闭   
		              				parent.location.reload();
		                  		});
		            		} else {
		            			layer.msg("添加失败",{icon:5,time:1500},function(){
		                			
		              			});
		            		} 
		            	},   	
		            	error: function() {
		                    layer.msg("数据异常", {icon: 2,time:1500});
		                }
		            });
		            
      			}else{
      				layer.msg("两次输入的密码不一致", {icon: 5,time:1500});
      			}
            return false;
          });
          
          
        });
    </script>

  </body>

</html>